package com.zklh.leetcode.other.problem409;

/**
 * @ClassName Solution
 * @Description
 * @Author 坐看落花
 * @Date 2020/3/19 15:23
 * @Version 1.0
 **/
public class Solution {


    public int longestPalindrome(String s) {
        // 用于存储所有字母的统计数, a对应的整数值为97
        int[] letterCounts = new int[52];
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            letterCounts[chars[i] >= 'a' ? chars[i]-71 : chars[i]-65]++;
        }
        int length = 0;
        for (int i = 0; i < letterCounts.length; i++) {
            length += letterCounts[i] % 2 == 0 ? letterCounts[i] : letterCounts[i]-1;
        }
        length = length == s.length() ? length : length+1;

        return length;
    }

    public static void main(String[] args){
        Solution solution = new Solution();
        System.out.println(solution.longestPalindrome("zeusnilemacaronimaisanitratetartinasiaminoracamelinsuez"));
        System.out.println(Character.toChars(91));
    }

}
